{{include template('public/header','admin')}}
<body>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">
                    <a href="/member/pay" class="btn btn-default bar-btn">入账记录</a>
                    <a href="/member/payspend" class="btn btn-default bar-btn">消费记录</a>
                    <a href="/member/member/recharge" class="btn btn-primary bar-btn">在线充值</a>
                </div>
                <div class="search">

                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <form id='cpform' name='cpform' method="post" action="" class="form-inline" role="form" onsubmit="return checkall()">
                    <table class="table table-border ticky_table">
                        <tr>
                            <td class="w_100">充值类型：</td>
                            <td>
                                <input name="type" type="radio" value="1" checked> 积分
                                <input name="type" type="radio" value="2" > 金钱
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100">用户名：</td>
                            <td><input type="text"class='form-control'name="username" id="username" value=""></td>
                        </tr>
                        <tr>
                            <td class="w_100">充值额度：</td>
                            <td>
                                <input name="unit" type="radio" value="1" checked> 增加
                                <input name="unit" type="radio" value="0" > 减少
                                <input type="text" class="form-control" name="money" id="money" value="" style="width:70px"> <span style="color:#888">输入修改数量（积分或金钱）</span>
                            </td>
                        </tr>
                        <tr>
                            <td class="w_100">备注说明：</td>
                            <td><textarea class="form-control" name="remarks" style="width:600px"></textarea></td>
                        </tr>
                        <tr>
                            <td class="w_100">提醒操作：</td>
                            <td> <input name="sendemail" value="1" type="checkbox"> 发送e-mail通知会员 <span style="color:#888">（需填写邮箱配置）</span></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <input class="btn btn-primary " name="dosubmit" type="submit" value="提交">
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $("#username").blur(function () {
                checkname();
            });

            $("#money").blur(function () {
                checkmoney();
            });
        })

        function checkname() {
            var res = false;
            if ($("#username").val() != '') {
                $.ajax({
                    type: "post",
                    url: "/member/home/public_checkname",
                    dataType: "html",
                    async: false,
                    data: "username=" + $('#username').val(),
                    success: function (msg) {
                        if (msg == '-1') {
                            res = true;
                        } else if (msg == '1') {
                            layer.msg('该用户不存在');
                        } else if (msg == '0') {
                            layer.msg('用户名格式不正确');
                        } else {
                            layer.msg('未知错误');
                        }
                    }
                });
                return res;
            } else {
                layer.msg('用户名不能为空');
                return res;
            }
        }

        function checkmoney() {
            if ($("#money").val() != '') {
                if (!isNaN($("#money").val())) {
                    return true;
                } else {
                    layer.msg('充值额度只能为数字');
                    return false;
                }
            } else {
                layer.msg('充值额度不能为空');
                return false;
            }
        }

        function checkall() {
            if (checkname() && checkmoney()) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</body>
</html>

